﻿import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import FilUI

Button {
    id: control

    property bool disabled                       : false
    property string contentDescription          : ""
    property color normalColor                  : FilTheme.primaryColor
    property color hoverColor                   : Qt.lighter(normalColor, 1.15)
    property color pressedColor                 : Qt.lighter(normalColor, 1.3)
    property color disableColor                 : Qt.rgba(199/255, 199/255, 199/255, 1)
    property color backgroundHoverColor         : FilTheme.itemHoverColor
    property color backgroundPressedColor       : FilTheme.itemPressColor
    property color backgroundNormalColor        : FilTheme.itemNormalColor
    property color backgroundDisableColor       : FilTheme.itemNormalColor
    property bool textBold                      : true
    property color textColor                    : {
        if (!enabled) {
            return disableColor
        }
        if (pressed) {
            return pressedColor
        }
        return hovered ? hoverColor : normalColor
    }

    horizontalPadding                           : 6
    enabled                                     : !disabled
    font                                        : FilTextStyle.Body
    background                                  : Rectangle {
        implicitWidth                           : 30
        implicitHeight                          : 30
        radius                                  : 4
        color                                   : {
            if (!enabled) {
                return backgroundDisableColor
            }
            if (pressed) {
                return backgroundPressedColor
            }
            if (hovered) {
                return backgroundHoverColor
            }
            return backgroundNormalColor
        }
        FilFocusRectangle {
            visible: control.visualFocus
            radius: 8
        }
    }
    focusPolicy                                 : Qt.TabFocus
    Accessible.role                             : Accessible.Button
    Accessible.name                             : control.text
    Accessible.description                      : contentDescription
    Accessible.onPressAction                    : control.clicked()
    contentItem                                 : FilText {
        id:btn_text
        text                                    : control.text
        font                                    : control.font
        horizontalAlignment                     : Text.AlignHCenter
        verticalAlignment                       : Text.AlignVCenter
        color                                   : control.textColor
    }
}
